package com.fhz.kotlinstest.pagingSource

import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import androidx.paging.Pager
import androidx.paging.PagingConfig
import androidx.paging.PagingData
import androidx.paging.cachedIn
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.Flow
import javax.inject.Inject

@HiltViewModel
class Pag3ViewModel @Inject constructor(var pag3Repository: Pag3Repository) : ViewModel() {


    val items: Flow<PagingData<String>> = Pager(
        config = PagingConfig(pageSize = 5, enablePlaceholders = false),
        pagingSourceFactory = { pag3Repository.getPag3Source() }
    ).flow.cachedIn(viewModelScope)
}